A mobile device such as a cellular phone or a smart phone can now be equipped with an electronic compass. The compass calculates and provides its user with a direction, which may be a “heading” (typically given relative to the Earth's magnetic field), and/or an arrow pointing to true north. The direction information may be provided for the user's own navigation knowledge, for example, to tell him which way is north while he is walking or driving in unfamiliar surroundings. The direction information is also beneficial for use by a navigation or map application that may be running in the device.
The electronic compass obtains a measure of the magnetic field that is present in its immediate surrounding as a three-component (e.g., in x, y, and z directions) vector, using a 3-axis magnetic sensor. The sensed field contains a contribution by the Earth's magnetic field, and a contribution by a so-called local interference field. The latter is the magnetic field that is created by components in the local environment of the mobile device. This may include contributions by any magnetic component that is near the sensor, such as a loudspeaker that is built into the device. The interference field may also have a contribution due to magnetic elements found in the external environment close to the device, such as when the user is driving an automobile, riding in a train or bus, or riding on a bicycle or motorcycle.